package com.ruoyi.web.controller.danger;


import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.entity.OneElectronFenceAlarm;
import com.ruoyi.system.service.OneElectronFenceAlarmService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 一号库区电子围栏报警信息(OneElectronFenceAlarm)表控制层
 *
 * @author makejava
 * @since 2023-10-25 13:43:02
 */
@RestController
@RequestMapping("oneElectronFenceAlarm")
public class OneElectronFenceAlarmController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private OneElectronFenceAlarmService oneElectronFenceAlarmService;

    /**
     * 分页查询
     *
     * @param oneElectronFenceAlarm 筛选条件
     * @return 查询结果
     */
    @GetMapping("/list")
    public TableDataInfo queryByPage(OneElectronFenceAlarm oneElectronFenceAlarm) {
        startPage();
        List<OneElectronFenceAlarm> oneElectronFenceAlarms = oneElectronFenceAlarmService.queryAll(oneElectronFenceAlarm);
        return getDataTable(oneElectronFenceAlarms);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public ResponseEntity<OneElectronFenceAlarm> queryById(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(this.oneElectronFenceAlarmService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param oneElectronFenceAlarm 实体
     * @return 新增结果
     */
    @PostMapping
    public ResponseEntity<OneElectronFenceAlarm> add(OneElectronFenceAlarm oneElectronFenceAlarm) {
        return ResponseEntity.ok(this.oneElectronFenceAlarmService.insert(oneElectronFenceAlarm));
    }

    /**
     * 编辑数据
     *
     * @param oneElectronFenceAlarm 实体
     * @return 编辑结果
     */
    @PutMapping
    public ResponseEntity<OneElectronFenceAlarm> edit(OneElectronFenceAlarm oneElectronFenceAlarm) {
        return ResponseEntity.ok(this.oneElectronFenceAlarmService.update(oneElectronFenceAlarm));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Integer id) {
        return ResponseEntity.ok(this.oneElectronFenceAlarmService.deleteById(id));
    }

}

